﻿using System;
using System.Drawing;
using System.Threading;
using System.Threading.Tasks;

namespace WholeSlideImageLibrary
{
    public abstract class WholeSlideImage : IAsyncDisposable
    {
        /// <summary>
        /// 总层数
        /// </summary>
        public abstract int LevelCount { get; }

        /// <summary>
        /// 获取某层的宽和高
        /// </summary>
        /// <param name="level"></param>
        /// <returns></returns>
        public abstract Size GetLevelSize(int level);

        /// <summary>
        /// 宽
        /// </summary>
        public virtual int Width => GetLevelSize(0).Width;

        /// <summary>
        /// 高
        /// </summary>
        public virtual int Height => GetLevelSize(0).Height;

        /// <summary>
        /// mppx
        /// </summary>
        public virtual double MicronsPerPixelX { get; }

        /// <summary>
        /// mppy
        /// </summary>
        public virtual double MicronsPerPixelY { get; }

        public abstract ValueTask ReadRegionAsync<T>(int level, int x, int y, int width, int height, Memory<T> buffer, CancellationToken cancellationToken) where T : unmanaged;

        public virtual ValueTask DisposeAsync() => default;
    }
}
